package com.bainaeco.framework.base.dao;

import java.util.Collection;
import java.util.List;

import com.bainaeco.framework.base.model.BaseModel;
import com.bainaeco.framework.common.jdbc.StatementParameter;
import com.bainaeco.framework.util.paging.PagingList;
import com.bainaeco.framework.util.paging.Sort;

public interface BaseDAO<T extends BaseModel> {
	
	/**
	 * Insert data
	 * @param object : Model
	 * @return
	 */
	public T insert(T object);
	
	/**
	 * Update data.
	 * @param object : Model
	 */
	public boolean update(T object);
	
	/**
	 * Update data.
	 * @param object : Model
	 * @param boolean : is set null
	 */
	public boolean update(T object, boolean isSetNull);
	
	/**
	 * Update data of is delete.
	 * @param cls
	 * @param id
	 */
	public boolean updateToDelete(final String id);
	
	/**
	 * Update data of is not delete.
	 * @param cls
	 * @param id
	 */
	public boolean updateToRestore(final String id);
	
	/**
	 * Delete data.
	 * @param t : Model
	 */
	public boolean delete(final T object);
	
	/**
	 * Delete data by id.
	 * @param cls : Model class
	 * @param id : id value
	 */
	public boolean delete(final String id);
	
	/**
	 * Delete data by ids.
	 * @param keys
	 * @return
	 */
	public boolean deleteByIds(final Collection<Object> keys);
	
	/**
	 * Batch insert data.
	 * @param list : Model list
	 * @return
	 */
	public int batchInsert(List<T> list);
	
	/**
	 * Batch update data.
	 * @param list : Model list
	 * @return
	 */
	public int batchUpdate(List<T> list);
	
	/**
	 * Batch update data.
	 * @param list : Model list
	 * @param boolean : Is set null
	 * @return
	 */
	public int batchUpdate(List<T> list, boolean isSetNull);
	
	/**
	 * Batch update data to delete by ids.
	 * @param ids : id values
	 * @return
	 */
	public boolean batchUpdateToDelete(final String... ids);
	
	/**
	 * Query model data.
	 * @param String : id value
	 * @return
	 */
	public T query(final String id);
	
	/**
	 * 
	 * @param id
	 * @return
	 */
	public List<T> findByBaseId(final String id);
	
	
	public List<T> findAll();
	
	public List<T> findByIds(final Collection<Object> keys);
	
	/**
	 * @param sql
	 * @param elementType
	 * @param param
	 * @param sort
	 * @param args int[] : pageNumber,maxPageRow
	 * @return
	 */
	@SuppressWarnings("hiding")
	public <T> PagingList<T> queryForPagingList(final String sql, final Class<T> elementType,
            StatementParameter param, final Sort sort, final int... args);
	
	/**
	 * @param sql
	 * @param elementType
	 * @param param
	 * @param sort
	 * @param args int[] : pageNumber,maxPageRow
	 * @return
	 */
	@SuppressWarnings("hiding")
	public <T> PagingList<T> queryForPagingList(final String sql, final Class<T> elementType,
            StatementParameter param, final int... args);
	
}
